module Fastlane
  module Actions
    module SharedValues
      UPDATE_OPENLIB_CUSTOM_VALUE = :UPDATE_OPENLIB_CUSTOM_VALUE
    end

    class UpdateOpenlibAction < Action
      def self.run(params)
        # fastlane will take care of reading in the parameter and fetching the environment variable:
        # UI.message "Parameter API Token: #{params[:api_token]}"
        repoName = params[:repo]
        Action.sh "pod repo update #{repoName}"
        # Actions.lane_context[SharedValues::UPDATE_OPENLIB_CUSTOM_VALUE] = "my_val"
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "更新本地私有库"
      end

      def self.details
        # Optional:
        # this is your chance to provide a more detailed description of this action
        "pod install 怕忘记"
      end

      def self.available_options
        # Define all options your action supports. 
        
        # Below a few examples
        [
          FastlaneCore::ConfigItem.new(key: :repo,
                                       description: "要更新的分支名称",
                                       is_string: true, # true: verifies the input is a string, false: every kind of value
                                       default_value: true) # the default value if the user didn't provide one
        ]
      end

      def self.output
      end

      def self.return_value
        # If your method provides a return value, you can describe here what it does
      end

      def self.authors
        # So no one will ever forget your contribution to fastlane :) You are awesome btw!
        ["Cai Xiang"]
      end

      def self.is_supported?(platform)
        # you can do things like
        # 
        #  true
        # 
        #  platform == :ios
        # 
        #  [:ios, :mac].include?(platform)
        # 

        platform == :ios
      end
    end
  end
end
